package com.jediflasher.game_client.server.messages {
	import com.netease.protobuf.*;
	import com.netease.protobuf.fieldDescriptors.*;
	import flash.utils.Endian;
	import flash.utils.IDataInput;
	import flash.utils.IDataOutput;
	import flash.utils.IExternalizable;
	import flash.errors.IOError;
	import com.jediflasher.game_client.server.messages.MessageType;
	import com.jediflasher.game_client.server.messages.ServiceType;
	// @@protoc_insertion_point(imports)

	// @@protoc_insertion_point(class_metadata)
	public dynamic final class Header extends com.netease.protobuf.Message {
		public static const REQUEST_ID:FieldDescriptor$TYPE_INT32 = new FieldDescriptor$TYPE_INT32("com.jediflasher.game_client.server.messages.Header.request_id", "requestId", (1 << 3) | com.netease.protobuf.WireType.VARINT);

		private var request_id$field:int;

		private var hasField$0:uint = 0;

		public function removeRequestId():void {
			hasField$0 &= 0xfffffffe;
			request_id$field = new int();
		}

		public function get hasRequestId():Boolean {
			return (hasField$0 & 0x1) != 0;
		}

		public function set requestId(value:int):void {
			hasField$0 |= 0x1;
			request_id$field = value;
		}

		public function get requestId():int {
			return request_id$field;
		}

		public static const SERVICE_TYPE:FieldDescriptor$TYPE_ENUM = new FieldDescriptor$TYPE_ENUM("com.jediflasher.game_client.server.messages.Header.service_type", "serviceType", (2 << 3) | com.netease.protobuf.WireType.VARINT, com.jediflasher.game_client.server.messages.ServiceType);

		private var service_type$field:int;

		public function removeServiceType():void {
			hasField$0 &= 0xfffffffd;
			service_type$field = new int();
		}

		public function get hasServiceType():Boolean {
			return (hasField$0 & 0x2) != 0;
		}

		public function set serviceType(value:int):void {
			hasField$0 |= 0x2;
			service_type$field = value;
		}

		public function get serviceType():int {
			return service_type$field;
		}

		public static const MESSAGE_TYPE:FieldDescriptor$TYPE_ENUM = new FieldDescriptor$TYPE_ENUM("com.jediflasher.game_client.server.messages.Header.message_type", "messageType", (3 << 3) | com.netease.protobuf.WireType.VARINT, com.jediflasher.game_client.server.messages.MessageType);

		public var messageType:int;

		public static const METHOD:FieldDescriptor$TYPE_INT32 = new FieldDescriptor$TYPE_INT32("com.jediflasher.game_client.server.messages.Header.method", "method", (4 << 3) | com.netease.protobuf.WireType.VARINT);

		private var method$field:int;

		public function removeMethod():void {
			hasField$0 &= 0xfffffffb;
			method$field = new int();
		}

		public function get hasMethod():Boolean {
			return (hasField$0 & 0x4) != 0;
		}

		public function set method(value:int):void {
			hasField$0 |= 0x4;
			method$field = value;
		}

		public function get method():int {
			return method$field;
		}

		public static const BODY_SIZE:FieldDescriptor$TYPE_INT32 = new FieldDescriptor$TYPE_INT32("com.jediflasher.game_client.server.messages.Header.body_size", "bodySize", (5 << 3) | com.netease.protobuf.WireType.VARINT);

		public var bodySize:int;

		public static const USER_ID:FieldDescriptor$TYPE_INT32 = new FieldDescriptor$TYPE_INT32("com.jediflasher.game_client.server.messages.Header.user_id", "userId", (6 << 3) | com.netease.protobuf.WireType.VARINT);

		private var user_id$field:int;

		public function removeUserId():void {
			hasField$0 &= 0xfffffff7;
			user_id$field = new int();
		}

		public function get hasUserId():Boolean {
			return (hasField$0 & 0x8) != 0;
		}

		public function set userId(value:int):void {
			hasField$0 |= 0x8;
			user_id$field = value;
		}

		public function get userId():int {
			return user_id$field;
		}

		/**
		 *  @private
		 */
		override public final function writeToBuffer(output:com.netease.protobuf.WritingBuffer):void {
			if (hasRequestId) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 1);
				com.netease.protobuf.WriteUtils.write$TYPE_INT32(output, request_id$field);
			}
			if (hasServiceType) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 2);
				com.netease.protobuf.WriteUtils.write$TYPE_ENUM(output, service_type$field);
			}
			com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 3);
			com.netease.protobuf.WriteUtils.write$TYPE_ENUM(output, messageType);
			if (hasMethod) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 4);
				com.netease.protobuf.WriteUtils.write$TYPE_INT32(output, method$field);
			}
			com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 5);
			com.netease.protobuf.WriteUtils.write$TYPE_INT32(output, bodySize);
			if (hasUserId) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 6);
				com.netease.protobuf.WriteUtils.write$TYPE_INT32(output, user_id$field);
			}
			for (var fieldKey:* in this) {
				super.writeUnknown(output, fieldKey);
			}
		}

		/**
		 *  @private
		 */
		override public final function readFromSlice(input:flash.utils.IDataInput, bytesAfterSlice:uint):void {
			var request_id$count:uint = 0;
			var service_type$count:uint = 0;
			var message_type$count:uint = 0;
			var method$count:uint = 0;
			var body_size$count:uint = 0;
			var user_id$count:uint = 0;
			while (input.bytesAvailable > bytesAfterSlice) {
				var tag:uint = com.netease.protobuf.ReadUtils.read$TYPE_UINT32(input);
				switch (tag >> 3) {
				case 1:
					if (request_id$count != 0) {
						throw new flash.errors.IOError('Bad data format: Header.requestId cannot be set twice.');
					}
					++request_id$count;
					requestId = com.netease.protobuf.ReadUtils.read$TYPE_INT32(input);
					break;
				case 2:
					if (service_type$count != 0) {
						throw new flash.errors.IOError('Bad data format: Header.serviceType cannot be set twice.');
					}
					++service_type$count;
					serviceType = com.netease.protobuf.ReadUtils.read$TYPE_ENUM(input);
					break;
				case 3:
					if (message_type$count != 0) {
						throw new flash.errors.IOError('Bad data format: Header.messageType cannot be set twice.');
					}
					++message_type$count;
					messageType = com.netease.protobuf.ReadUtils.read$TYPE_ENUM(input);
					break;
				case 4:
					if (method$count != 0) {
						throw new flash.errors.IOError('Bad data format: Header.method cannot be set twice.');
					}
					++method$count;
					method = com.netease.protobuf.ReadUtils.read$TYPE_INT32(input);
					break;
				case 5:
					if (body_size$count != 0) {
						throw new flash.errors.IOError('Bad data format: Header.bodySize cannot be set twice.');
					}
					++body_size$count;
					bodySize = com.netease.protobuf.ReadUtils.read$TYPE_INT32(input);
					break;
				case 6:
					if (user_id$count != 0) {
						throw new flash.errors.IOError('Bad data format: Header.userId cannot be set twice.');
					}
					++user_id$count;
					userId = com.netease.protobuf.ReadUtils.read$TYPE_INT32(input);
					break;
				default:
					super.readUnknown(input, tag);
					break;
				}
			}
		}

	}
}
